package com.dididoctor.patient.Dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.dididoctor.patient.Activity.ConstantValue;
import com.dididoctor.patient.Bean.Token;
import com.dididoctor.patient.Http.MyHttpResponseHandler;
import com.dididoctor.patient.MV.BaseDialog;
import com.dididoctor.patient.MV.BusinessClient;
import com.dididoctor.patient.MV.Response;
import com.dididoctor.patient.R;
import com.loopj.android.http.RequestParams;


/**
 * @version 2.0
 * @类描述：退出登录Dialog
 * @项目名称：ddgh
 * @类名称： LoginOutDialog
 * @包名称： com.doudoukeji.service.Dialog
 * @创建人： zhanjunjie
 * @创建时间：2016/3/18 17:01
 * @修改人：
 * @修改时间：2016/3/18 17:01
 * @修改备注： new parent class(用一句话描述修改了什么)
 */
public class LoginOutDialog extends BaseDialog {

    private TextView mTvConfirm, mTvCancel;
    private Context context;
    private Outlogin outlogin;

    public LoginOutDialog(Context context, Outlogin outlogin) {
        super(context);
        this.context = context;
        this.outlogin = outlogin;
        setContentView(R.layout.dialog_loginout);
        mTvConfirm = (TextView) findViewById(R.id.tv_confirm);
        mTvConfirm.setOnClickListener(this);
        mTvCancel = (TextView) findViewById(R.id.tv_cancel);
        mTvCancel.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_confirm:
                RequestParams params = new RequestParams();
                params.put("userId", Token.getId());
                params.put("token", Token.getToken());
                BusinessClient.post(ConstantValue.logout, params, new MyHttpResponseHandler() {
                    @Override
                    public void onMyResponse(Response response) {
                    }
                });
                outlogin.outlogin();
                dismiss();
                break;
            case R.id.tv_cancel:
                dismiss();
                break;
            default:
                break;
        }
        super.onClick(v);
    }

    public interface Outlogin {
        void outlogin();
    }

}
